<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<title>修改密码--layui后台管理模板 2.0</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form layui-row changePwd">
	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
		<div class="layui-form-item">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-block">
				<input type="text"  disabled class="layui-input layui-disabled" th:value="${session.currUser.name}">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">旧密码</label>
			<div class="layui-input-block">
				<input type="password" name = "oldPassword" id = "oldPassword" placeholder="请输入旧密码" lay-verify="required" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">新密码</label>
			<div class="layui-input-block">
				<input type="password" name="newPassword" id ="newPassword" placeholder="请输入新密码" lay-verify="required"  class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">确认密码</label>
			<div class="layui-input-block">
				<input type="password" name ="newPassword1" id ="newPassword1" placeholder="请确认密码" lay-verify="required" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="changePwd">立即修改</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</div>
</form>
<script type="text/javascript" src="/resources/layui/layui.js"></script>
<!-- <script type="text/javascript" src="/resources/page/user/user.js"></script> -->
<script type="text/javascript">
	layui.use(['form','layer','jquery'],function(){
		var form = layui.form;
		var layer = layui.layer;
		var $ = layui.jquery;
		var newPassword = $("#newPassword").val;
		var newPassword1 = $("#newPassword1").val;
		if(newPassword != newPassword1){
			layer.msg("两次密码输入不一致,请重新输入");
			return false;
		}else{
			form.on("submit(changePwd)",function(d){
				$.post("/sys/user/changePassword",d.field,function(rs){
					if(rs.code == 200){
						window.parent.location="/sys/user/loginOut";
					}else{
						layer.msg(rs.msg);
					}
				});
				return false;
			})
		}
		
	})
</script>
</body>
</html>